/*
 * battery.c
 *
 * Created: 03.01.2014 17:46:02
 *  Author: Timmo
 */ 

#include <avr/io.h>
#include "battery.h"
#include "settings.h"

void set_charge_current(){
	// Set charge current to 500mA if enabled
	if(mt_settings.charge_current == 1){
		PORTD.DIRSET = (1<<PIN0);
		PORTD.OUTCLR = (1<<PIN0);
	}
	else{
		PORTD.DIRCLR = (1<<PIN0);
		PORTD.OUTCLR = (1<<PIN0);
	}
	
}

uint8_t get_battery_charge_state(){
	//PORTD.PIN5CTRL = PORT_OPC_PULLDOWN_gc;
	if( PORTD.IN & (1<<PIN5) ){
		return BATTERY_STATE_COMPLETE;	
	}
	else{
		return BATTERY_STATE_SHUTDOWN;
	}
	
}